﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Mail;
using System.Text;
using System.Web;
using System.Web.Mvc;
using ZhongheCms.Models;

namespace ZhongheCms.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {

            //and HotFlag=1
            var strsql = "select top 8 *  from GswTblJobInfo  where  ParentId=19  and JobState=1 and delflag=0 and RegisterNum<JobNum order by id desc";
                
            var qry = new HomeModel
            {
              
                Tiebas = GswTblTieba.Fetch("select top 8 * from GswTblTieba where ParentId=19 order by id desc"),
                HomeContents = GswTblHomeContent.Fetch("where 0=0 order by id desc"),
                //sql = "  where  ParentId=19 and HotFlag=1 and JobState=1 order by id desc";
                JobInfos = GswTblJobInfo.Fetch(strsql),
                HomeJobInfos = GswTblHomeJobInfo.Fetch("where  ReFlag=1  order by jobno")
              

            };
            ViewBag.isindex = 1;
            return View(qry);
        }

        public ActionResult ContentShow(int id)
        {
            var qry = GswTblContent.SingleOrDefault(id);
            qry.ContentList0 = GswTblContent.Fetch("select top 10 * from GswTblContent where CustomerId=19 and Id<>" + id + " and FunctionId=81 order by id");
            qry.JobInfos = GswTblJobInfo.Fetch(
                "select top 10 * from GswTblJobInfo where ParentId=19 and JobState=1 and delFlag=0 order by id desc");
            return View(qry);
        }

        public ActionResult AboutDesc(int id)
        {
            var qry = GswTblContent.SingleOrDefault(id);
            qry.ContentList0 = GswTblContent.Fetch("where CustomerId=19 and Id<>"+id+" and (FunctionId=92 or FunctionId=93 ) order by id");
            return View(qry);
        }
        public ActionResult Admin()
        {
            if (GswTblUser.CurrentUser == null)
                return RedirectToAction("Login", "Account");
            GswTblUser.CurrentUser.ModuleName = "";
            GswTblUser.CurrentUser.FuncName = "";
            var qry = GswTblMemberBase.Fetch("where AuditFlag<>1 order by id desc");
            return View(qry);
        }
        [ChildActionOnly]
        public ActionResult PageFooter()
        {
            var qry = GswTblContent.Fetch("where CustomerId=19 and (FunctionId=92 or FunctionId=93 )");
            return View(qry);
        }

        [ChildActionOnly]
        public ActionResult IndexSideMenu()
        {
            var qry = GswTblBaseInfo.Fetch("select top 7 * from GswTblBaseInfo where CustomerId=19 and FunctionId=59 and NewFlag=1 order by typeno");
            return View(qry);
        }
      

    }
}
